# -*- coding: utf-8 -*-            
# @Author : liguang
# @Time : 2023/11/17 14:28

try:
    f = open("D:/li.txt", "r", encoding='utf-8')
    print("开始来进行操作")
    f.close()
except:
    print("当前文件出现了异常，因为当前文件不存在!开始来创建文件")
    f = open("D:/li.txt", "w", encoding='utf-8')

print("-----------------------捕获指定异常--------------------------------")

try:
    f = open("D:/li.txt", "r", encoding='utf-8')
    print("开始来进行操作")
    f.close()
except FileNotFoundError as e:
    print(f"当前的异常是：{e}")
    print("当前文件出现了异常，因为当前文件不存在!开始来创建文件！")
    f = open("D:/li.txt", "w", encoding='utf-8')
